package com.huangliusong.lengthoflongestsubstring;

import java.util.HashSet;
import java.util.Set;

/**
 * @author huangliusong
 * @since 2019/2/21
 * {@link }
 */
public class Test1 {
    public static void main(String[] args) {
        String s="abccbcbcde";
        int ans=0,i=0,j=0;
        int n=s.length();
        Set<Character> set=new HashSet<Character>();
        while (i<n&&j<n){
            if(!set.contains(s.charAt(j))){
                set.add(s.charAt(j++));
                ans=Math.max(ans,j-i);
            }
            else
            {
                set.remove((s.charAt(i++)));
            }
        }
        System.out.println(ans);
    }
}
